package com.corpgovernment.travelstandard.impl;

import com.corpgovernment.travelstandard.entity.db.MbTravelstandCarDatetime;
import com.corpgovernment.travelstandard.mapper.MbTravelstandCarDatetimeMapper;
import com.ctrip.corp.obt.generic.utils.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
@Slf4j
public class MbTravelstandCarDatetimeService  {

    @Autowired
    private MbTravelstandCarDatetimeMapper mbTravelstandCarDatetimeMapper;

    public List<MbTravelstandCarDatetime> selectByTsid(String tsId){
        Example example = new Example(MbTravelstandCarDatetime.class);
        example.createCriteria().andEqualTo("tsid", tsId);
        return mbTravelstandCarDatetimeMapper.selectByExample(example);
    }

    public List<MbTravelstandCarDatetime> selectByTsids(List<Long> tsIds){
        Example example = new Example(MbTravelstandCarDatetime.class);
        example.createCriteria().andIn("tsid", tsIds);
        return mbTravelstandCarDatetimeMapper.selectByExample(example);
    }

    public boolean saveBatch(List<MbTravelstandCarDatetime> datetimeList){
        if (CollectionUtils.isEmpty(datetimeList)){
            return false;
        }
        int result = mbTravelstandCarDatetimeMapper.insertList(datetimeList);
        return result > 0;
    }

    public boolean delByTsid(String tsId){
        Example example = new Example(MbTravelstandCarDatetime.class);
        example.createCriteria().andEqualTo("tsid", tsId);
        int result = mbTravelstandCarDatetimeMapper.deleteByExample(example);
        return result > 0;
    }

}
